import { Component, EventEmitter, Output } from '@angular/core';
import { SiteOrientation } from 'src/components/scenarios/enums';
import { SiteNodeConfig } from 'src/components/scenarios/models';
import { SiteNode } from 'src/components/scenarios/nodes/SiteNode';
import { InfoSidebar } from '../../InfoSidebar';

@Component({
  selector: 'app-site-info',
  templateUrl: './site-info.component.html',
  styleUrl: './site-info.component.scss'
})
export class SiteInfoComponent implements InfoSidebar {
  orientations: SiteOrientation[] = Object.values(SiteOrientation);
  sidebarRightVisible: boolean = false;
  cfg?: SiteNodeConfig;
  @Output()
  onHide: EventEmitter<SiteNodeConfig> = new EventEmitter();
  item?: SiteNode;

  get status() {
    return this.item?.data.Values?.Status;
  }

  onShow(cfg: SiteNodeConfig, item: SiteNode) {
    this.cfg = cfg;
    this.item = item;
    this.sidebarRightVisible = true;
  }
  onSidebarHide() {
    this.sidebarRightVisible = false;
    this.onHide.next(this.cfg!);
    this.cfg = undefined;
    this.item = undefined;
  }

}
